/*
 * @Author: taoshiwei
 * @Date: 2019-04-09 14:39:32
 * @Last Modified by: taoshiwei
 * @Last Modified time: 2019-04-29 15:16:53
 *
 * 文章
 */

import { createAPI } from '@/utils/request'

/**
 * 获取文章列表
 * @param {*} data
 * @returns
 */
export const list = data => createAPI('/articles', 'get', data)

/**
 * 文章的简单列表
 * @param {*} data
 * @returns
 */
export const simple = data => createAPI('/articles/simple', 'get', data)

/**
 * 文章详情
 * @param {*} data
 * @returns
 */
export const detail = data => createAPI(`/articles/${data.id}`, 'get', data)

/**
 * 文章添加
 * @param {*} data
 * @returns
 */
export const add = data => createAPI('/articles', 'post', data)

/**
 * 文章修改
 * @param {*} data
 * @returns
 */
export const update = data => createAPI(`/articles/${data.id}`, 'put', data)

/**
 * 文章删除
 * @param {*} data
 * @returns
 */
export const remove = data => createAPI(`/articles/${data.id}`, 'delete', data)

/**
 * 文章的状态
 * @param {*} data
 * @returns
 */
export const changeState = data =>
  createAPI(`/articles/${data.id}/${data.state}`, 'post', data)
